package edu.pku.sei.transformation.editor.controller.commands.node;

import edu.pku.sei.modeler.model.structure.MetaNode;

public class NestedNodeDeleteCommand extends NestedCommand {

	private MetaNode node;
	private MetaNode father;

	public NestedNodeDeleteCommand(MetaNode node, MetaNode father) {
		this.node = node;
		this.father = father;
	}

	@Override
	public boolean canExecute() {
		if (this.node != null && this.father != null) {
			return super.canExecute();
		} else {
			return false;
		}
	}

	@Override
	public void execute() {
		father.getSubNodes().remove(node);
		if (modelCmd != null) {
			modelCmd.execute();
		}
	}

	@Override
	public void undo() {
		father.getSubNodes().add(node);
		if (modelCmd != null) {
			modelCmd.undo();
		}
	}
}
